package com.lxw.study.behavioral.responsibilitychain.linked;

public abstract class Handler {
    protected Handler nextHandler = null;

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public final void handle() {
        boolean handled = doHandle();
        if (nextHandler != null && !handled) {
            nextHandler.handle();
        }
    }

    protected abstract boolean doHandle();
}

